﻿@extends('layouts.shop_main')

@section('title', '首页')

@section('resources')
    @parent
    <style>
        .index_timer{overflow: hidden;margin: 15px 40px;}
        .index_timer li{float: left;margin-left: 10px;font-size: 16px;}
        .main-stats .title{margin: 20px 50px;font-size: 16px;border-left: 3px solid #9955c6;padding-left: 20px;}
        .main-stats .isdouble{margin: 20px 50px;font-size: 16px;padding-left: 23px;}
        .spread{margin: 10px 50px;font-size: 16px;color: #9955c6;}
        .statsChart{text-align: center;background: rgba(0,0,0,0.15);color: #fff;font-size: 18px;width: 250px;height: 50px;line-height: 50px;border-radius: 5px;margin: 50px auto;}
    </style>
@endsection

@section('content')
	<!-- main container -->
    <div class="content">
        <ul class="index_timer">
            <li>{{date('Y-m-d')}}</li>
            @if(date('w') == 1)
            <li>星期一</li>
            @elseif(date('w') == 2)
            <li>星期二</li>
            @elseif(date('w') == 3)
            <li>星期三</li>
            @elseif(date('w') == 4)
            <li>星期四</li>
            @elseif(date('w') == 5)
            <li>星期五</li>
            @elseif(date('w') == 6)
            <li>星期六</li>
            @elseif(date('w') == 7)
            <li>星期天</li>
            @endif
            {{--<li>妇女节</li>--}}
            <li>
                @if($todayevent)
                    <p  class="isdouble">今天是翻倍日</p>
                @else
                    @if($nextevent != '0000-00-00')
                        <p  class="isdouble">今天不是翻倍日，最近翻倍日是{{date('Y-m-d', strtotime($nextevent))}}</p>
                    @else
                        <p  class="isdouble">今天不是翻倍日，最近无翻倍日</p>
                    @endif
                @endif
            </li>
        </ul>
        <div class="main-stats">
            <div class="row stats-row">
                <div class="col-md-3 col-sm-3 stat">
                    <div class="data">
                    @if($todayordercount==0 || $todayordercount == '')
                        <span class="number">--</span>
                    @else
                         <span class="number">{{$todayordercount}}</span>
                    @endif
                    </div>
                    <span class="date">今天订单数</span>
                </div>
                <div class="col-md-3 col-sm-3 stat">
                    <div class="data">
                    @if($todayordersum==0 || $todayordersum == '')
                        <span class="number">--</span>
                    @else
                        <span class="number">{{$todayordersum}}</span>
                    @endif
                    </div>
                    <span class="date">今日订单消费金额</span>
                </div>
                <div class="col-md-3 col-sm-3 stat">
                    <div class="data">
                    @if($todaysalesmancount==0 || $todaysalesmancount == '')
                        <span class="number">--</span>
                    @else
                        <span class="number">{{$todaysalesmancount}}</span>
                    @endif
                    </div>
                    <span class="date">今日地推注册数</span>
                </div>
                <div class="col-md-3 col-sm-3 stat last">
                    <div class="data">
                    @if($todaysalesmansum == 0 || $todaysalesmansum == '')
                        <span class="number">--</span>
                    @else
                        <span class="number">¥{{$todaysalesmansum}}</span>
                    @endif
                    </div>
                    <span class="date">今日地推收入(元)</span>
                </div>
            </div>
        </div>
        <!-- 单门店展示 -->
        <div class="pad-wrapper" style="padding: 0 40px;">
            <div class="row chart">
                <div class="col-md-12">
                    <h4 class="clearfix">
                        最近7个翻倍日订单数变化
                    </h4>
                </div>
                <div class="col-md-12">
                    <div id="statsChart"></div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scriptResources')
    @parent
    <script>
<!-- 单条曲线 -->
var shopid='{{$shopid}}';
var orders = [];
var ticks = [];
$.ajax({
    url :"/shop/order/event/chart",
    type:'get',
    data : {
        shopid:shopid
    },
    dataType:'json',
    async:true,
    success:function(data){
        if (data.status == "success") {
            var data = data.data;
            orders = data['ylabel'];
            ticks = data['xlabel'];
            var isshow = data['isshow'];
            if(isshow == 1){
                var plot = $.plot($("#statsChart"),
                    [
                        { data: orders, label: "订单数"}
                    ],
                    {
                        series: {
                            lines: { show: true,
                                    lineWidth: 1,
                                    fill: true,
                                    fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.13 } ] }
                                 },
                            points: { show: true,
                                     lineWidth: 2,
                                     radius: 3
                                 },
                            shadowSize: 0,
                            stack: true
                        },
                        grid: { hoverable: true,
                               clickable: true,
                               tickColor: "#f9f9f9",
                               borderWidth: 0
                            },
                        legend: {
                                // show: false
                                labelBoxBorderColor: "#fff"
                            },
                        colors: ["#a7b5c5",  "#30a0eb"],
                        xaxis: {
                            ticks: ticks,
                            font: {
                                size: 12,
                                family: "Open Sans, Arial",
                                variant: "small-caps",
                                color: "#697695"
                            }
                        },
                        yaxis: {
                            ticks:3,
                            tickDecimals: 0,
                            font: {size:12, color: "#9da3a9"}
                        }
                    });
            }else{
                $("#statsChart").html("暂无数据");
                $("#statsChart").addClass('statsChart');
                $("#statsChart").css({"height":"50px","margin-top":"50px"});
            }
        } else {
            //alert(data.message);
        }
    }
});

    </script>
@endsection